package com.dingdang.sms.allinone.sender

class Target {
    var mobileList: List<String>? = null
    //腾讯、京东，因为参数格式是List，key可以无所谓，但是value一定要注意和短信模板里面的参数的顺序一致
    var params: LinkedHashMap<String, String>? = null
    var templateId: String? = null
    //阿里云 语音文字短信，语音号码
    var voiceNumber: String? = null
    //腾讯短信类型, 默认 0
    var tencentType: Int = 0
    //国家编码 eg:86。 只针对腾讯云
    var nationCode: String? = null
        get() {
            return if (field.isNullOrEmpty()) {
                "86"
            } else field
        }

    fun isSingleTarget(): Boolean {
        checkMobileList()
        return mobileList!!.size == 1
    }

    fun checkMobileList() {
        if (!(mobileList != null && mobileList?.size != 0)) {
            throw IllegalArgumentException("mobileList不能为空")
        }
        if (mobileList!!.any { it.isEmpty() }) {
            throw IllegalArgumentException("mobileList中不能包含null和\"\"空字符串")
        }
    }

    fun checkTemplateId() {
        if (templateId.isNullOrEmpty()) {
            throw IllegalArgumentException("templateId不能为空")
        }
    }

    fun checkVoiceNumber() {
        if (voiceNumber.isNullOrEmpty()) {
            throw IllegalArgumentException("voiceNumber不能为空")
        }
    }
}